/**
 * Copyright 2008 by Robert Konigsberg
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the same terms as Perl.
 *
 * @see http://www.perl.com/perl/misc/Artistic.html
 */
package visitor.maze;

import org.testng.annotations.Test;

@Test
public class DirectionTest {

  @Test
  public void testLeft() {
    for (Direction direction : Direction.values()) {
      assert direction.left() != direction;
      assert direction.left().left() != direction;
      assert direction.left().left().left() != direction;
      assert direction.left().left().left().left() == direction;
    }
  }

  @Test
  public void testRight() {
    for (Direction direction : Direction.values()) {
      assert direction.right() != direction;
      assert direction.right().right() != direction;
      assert direction.right().right().right() != direction;
      assert direction.right().right().right().right() == direction;
    }
  }

  @Test
  public void testRelative() {
    for (Direction direction : Direction.values()) {
      assert direction.left() == direction.right().right().right();
      assert direction.left() != direction.opposite();
      assert direction.left().left() == direction.right().right();
      assert direction.left().left() == direction.opposite();
      assert direction.left().left().left() == direction.right();
      assert direction.left().left().left() != direction.opposite();
    }
  }

  @Test
  public void testActual() {
    assert Direction.NORTH.right() == Direction.EAST;
    assert Direction.NORTH.left() == Direction.WEST;
    assert Direction.NORTH.opposite() == Direction.SOUTH;

    assert Direction.EAST.right() == Direction.SOUTH;
    assert Direction.EAST.left() == Direction.NORTH;
    assert Direction.EAST.opposite() == Direction.WEST;

    assert Direction.SOUTH.right() == Direction.WEST;
    assert Direction.SOUTH.left() == Direction.EAST;
    assert Direction.SOUTH.opposite() == Direction.NORTH;

    assert Direction.WEST.right() == Direction.NORTH;
    assert Direction.WEST.left() == Direction.SOUTH;
    assert Direction.WEST.opposite() == Direction.EAST;

  }

  @Test
  public void testOpposite() {
    for (Direction direction : Direction.values()) {
      assert direction.opposite() != direction;
      assert direction.opposite().opposite() == direction;
    }
  }

}
